package com.main;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

/**
 * Main.java
 *
 * @author www.javadb.com
 */
public class MainCrawler {
    
    /**
     * Reads a web page into a StringBuilder object
     * and prints it out to console along with the
     * size of the page.
     */
	String url = "http://download.oracle.com/javase/1.5.0/docs/api/java/lang/StringBuilder.html";
	String url2	= "http://www.albany.edu/~pc387169";
    public void getWebSite() {
        
        try {
            
            URL url = new URL(url2);
            URLConnection urlc = url.openConnection();
            
            BufferedInputStream buffer = new BufferedInputStream(urlc.getInputStream());
            
            StringBuilder builder = new StringBuilder();
            int byteRead;
            while ((byteRead = buffer.read()) != -1)
                builder.append((char) byteRead);
            
            buffer.close();
            
            System.out.println(builder.toString());
            System.out.println("The size of the web page is " + builder.length() + " bytes.");
            
        } catch (MalformedURLException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
    /**
     * Starts the program
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new MainCrawler().getWebSite();
    }
}
